<template>
  <tbody>
    <tr v-for="(item, index) in arr" :key="index">
      <th><input type="checkbox" v-model="item.checked" /></th>
      <th>{{ item.name }}</th>
      <th>
        {{ item.price }}
      </th>
      <th>
        <button @click="jian(index)">-</button>
        {{ item.num }}
        <button @click="jia(index)">+</button>
      </th>
      <th>{{ item.num * item.price }}</th>
      <th><button @click="del(index)">删除</button></th>
    </tr>
  </tbody>
</template>

<script>
export default {
  props: ["arr"],
  methods: {
    jia(index) {
      this.$emit("getjia", index);
    },
    jian(index) {
      this.$emit("getjian", index);
    },
    del(index) {
      this.$emit("getdel", index);
    },
  },
};
</script>